﻿using KayakMes.Common.Dtos.ProcessDTO.Input;
using KayakMes.Common.Dtos.ProcessDTO.Output;
using KayakMes.Common.Result;
using KayakMes.ProcessManagement.Application.Process;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace KayakMes.ProcessManagement.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessManagementController : ControllerBase
    {
        private readonly IProcessStepUpService processStepUpService;
        private readonly ITechnologicalFlowService _rechnologicalFlowService;

        public ProcessManagementController(IProcessStepUpService processStepUpService, ITechnologicalFlowService rechnologicalFlowService)
        {
            this.processStepUpService = processStepUpService;
            _rechnologicalFlowService = rechnologicalFlowService;
        }

        //-------------------------------   工序设置   ----------------------------------

        /// <summary>
        /// 新增工序设置信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddProcessStepUp(ProcessStepUpInput input)
        {
            return processStepUpService.Add(input);
        }
        /// <summary>
        /// 查询供需信息列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<ProcessStepUpOutput> GetProcessStepUpList([FromQuery]GetProcessStepUpInput input)
        {
            return processStepUpService.GetProcessStepUpList(input);
        }
        /// <summary>
        /// 根据Id获取工序设置信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<ProcessStepUpOutput> FindProcessStepUp(long id)
        {
            return processStepUpService.FindProcessStepUp(id);
        }


        /// <summary>
        /// 根据ID删除工序设置信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> DeleteProcessStepUp(long id)
        {
            return processStepUpService.DeleteProcessStepUp(id);
        }

        /// <summary>
        /// 修改工序设置信息
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateProcessStepUp(ProcessStepUpOutput output)
        {
            return processStepUpService.UpdateProcessStepUp(output);
        }




        //-------------------------------   工艺流程  ----------------------------------


        /// <summary>
        /// 新增工艺流程信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddTechnologicalFlow(TechnologicalFlowInput input)
        {
            return _rechnologicalFlowService.Add(input);
        }
        /// <summary>
        /// 查询工艺流程信息列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<TechnologicalFlowOutput> GetTechnologicalFlowList([FromQuery]GetTechnologicalFlowInput input)
        {
            return _rechnologicalFlowService.GetTechnologicalFlowList(input);
        }

        /// <summary>
        /// 通过Id查询工艺流程信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<TechnologicalFlowOutput> FindTechnologicalFlow([FromQuery]long id)
        {
            return _rechnologicalFlowService.FindTechnologicalFlow(id);
        }

        /// <summary>
        /// 根据ID删除工序设置信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> DeleteTechnologicalFlow(long id)
        {
            return _rechnologicalFlowService.DeleteTechnologicalFlow(id);
        }

        /// <summary>
        /// 修改工序设置信息
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateTechnologicalFlow(TechnologicalFlowOutput output)
        {
            return _rechnologicalFlowService.UpdateTechnologicalFlow(output);
        }
    }
}
